package com.fadadianqi.logistics.inventory.dao.ibatis;

import com.fadadianqi.commons.GenericDAOSuport;
import com.fadadianqi.logistics.inventory.dao.BatchDAO;
import com.fadadianqi.logistics.inventory.model.Batch;
import com.yeqiangwei.commons.util.Pagination;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class BatchDAOImpl extends GenericDAOSuport<String, Batch> implements BatchDAO {

    @Override
    protected Class<?> getObjectClass() {
        return Batch.class;
    }

    @Override
    protected String getTableName() {
        return "stock_batch";
    }

    @Override
    public List<Batch> findAll(String goodsId, String categoryId, String brandId,
                               Pagination pagination) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(Batch.PROP_GOODS_ID, goodsId);
        map.put(Batch.PROP_CATEGORY_ID, categoryId);
        map.put(Batch.PROP_BRAND_ID, brandId);
        map.put("pagination", pagination);
        return super.findByPropertys(map);
    }

    @Override
    public int count(String goodsId, String brandId, String categoryId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put(Batch.PROP_GOODS_ID, goodsId);
        map.put(Batch.PROP_CATEGORY_ID, categoryId);
        map.put(Batch.PROP_BRAND_ID, brandId);
        return super.countAll(map);
    }
}
